package br.com.estevam.sisfin.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.tapestry5.beaneditor.Validate;
import org.apache.tapestry5.ioc.annotations.Inject;

@Entity
@Table(name = "TblUsuario")
public class Usuario extends AbstractEntity {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;
	
	@Column(length = 20, nullable = false, unique = true)
	@Validate("required,minlength=3")
	private String login;
	
	@Column(length = 32, nullable = false)
	@Validate("required,minlength=3")
	private String password;
	
	@Column(length = 50, nullable = false)
	@Validate("required,minlength=3")
	private String name;
	
	@Column(length = 30, nullable = false)
	@Validate("email")
	private String email;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false)
	private Date dateNew;
	
	@Column(nullable = false)
	private boolean status;
	
	@Inject
	public Usuario() { }

	public Usuario(String login, String password, String name, String email,
			Date dateNew, boolean status) {
		super();
		this.login = login;
		this.password = password;
		this.name = name;
		this.email = email;
		this.dateNew = dateNew;
		this.status = status;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getDateNew() {
		return dateNew;
	}

	public void setDateNew(Date dateNew) {
		this.dateNew = dateNew;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}
	
	public String toString(){
		return "" + id + "---" + getUserId();
	}

}
